/* This software is distributed under the Lesser General Public License */
//
// Attributes.cpp
//
// This file implements the classes
//   GT_Attribute_Base
//   GT_Attribut<T>
//   GT_Attributes
//   GT_List_of_Attributes
//
//------------------------------------------ CVS
//
// CVS Headers -- The following headers are generated by the CVS
// version control system. Note that especially the attribute
// Author is not necessarily the author of the code.
//
// $Source: /home/br/CVS/graphlet/src/gt_base/Attribute_int.cpp,v $
// $Author: himsolt $
// $Revision: 1.2 $
// $Date: 1999/03/05 20:42:59 $
// $Locker:  $
// $State: Exp $
//
//------------------------------------------ CVS
//
// (C) University of Passau 1995-1999, graphlet Project
//

#include "Graphlet.h"
#include "GML.h"
#include "Key_description.h"

#include "Attribute_int.h"


//////////////////////////////////////////
//
// class GT_Attribute_int
//
//////////////////////////////////////////


GT_Attribute_int::GT_Attribute_int (const GT_Key key, const int& i,
    const int flags) :
	GT_Attribute_Base (key, flags)
{
    the_value = i;
    the_flags |= the_is_int;
}


GT_Attribute_int::~GT_Attribute_int()
{
}


//////////////////////////////////////////
//
// Cloning
//
//////////////////////////////////////////


void GT_Attribute_int::copy (const GT_Attribute_int* from,
    GT_Copy type)
{
    GT_Attribute_Base::copy (from, type);
    the_value = from->the_value;
}


GT_Attribute_Base* GT_Attribute_int::clone (GT_Copy /* type */) const
{
    if (the_flags | the_is_safe) {
	return new GT_Attribute_int (the_key, the_value, the_flags);
    } else {
	return 0;
    }
}



//////////////////////////////////////////
//
// Printing
//
//////////////////////////////////////////


void GT_Attribute_int::print (ostream &out) const
{
    if (the_key.description()->safe() || (the_flags & the_is_safe)) {
	baseclass::print (out);
	GT_print (out, the_value);
    }
}



//////////////////////////////////////////
//
// Value access
//
//////////////////////////////////////////


bool GT_Attribute_int::value_int (int& i) const
{
    i = the_value;
    return true;
}
